<template>
	<view>
		<uniNavBar color="white" @clickLeft="clickNavLeft()">

			<view slot="left">
				<view class="left">
					<svg t="1636992389823" class="icon" viewBox="0 0 1024 1024" version="1.1"
						xmlns="http://www.w3.org/2000/svg" p-id="1743" width="200" height="200">
						<path
							d="M781.566553 1011.699354L168.659015 540.690841c-20.402945-16.0254-20.402945-42.009075 0-58.034474L781.566553 11.647854c20.377345-16.0254 53.400932-16.0254 73.778278 0 20.377345 15.9998 20.377345 42.009075 0 58.008875L279.326431 511.686404l576.0184 442.004075c20.377345 15.9998 20.377345 41.983475 0 58.008875-20.377345 16.0254-53.400932 16.0254-73.778278 0z"
							p-id="1744" fill="#ffffff"></path>
					</svg>
				</view>
			</view>
			<view slot="default" style="position:absolute;left: 40%;font-size: 37rpx;font-weight: 700;">管理教室</view>
			<view slot="right"></view>
		</uniNavBar>
		<view v-for="item in ClassRoomList">
			<itemList :item="item" @uptade="uptade"></itemList>
		</view>
	</view>
</template>

<script>
	import itemList from "../../components/itemListClass/itemListClass.vue"
	import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
	export default {

		data() {
			return {
				ClassRoomList: [],
				newres: {}
			}
		},
		onLoad() {
			this.getClassRooms()
		},

		methods: {
			clickNavLeft(){
			
				uni.switchTab({
					url:"/pages/home/home"
				})
			},
			uptade() {
				this.getClassRooms()
			},
			async getClassRooms() {
				console.log("获取数据") /*获取到课室的相关信息*/

				const res = await this.$myRequest({
				 url: "/classRooms"
				})

				for (let index = 0; index < res.data.data.length; index++)
					if (res.data.data[index].rStatus == "1") {
						res.data.data[index].rStatus = true
						this.newres[index] = res.data.data[index]
					}
				else {
					res.data.data[index].rStatus = false
					this.newres[index] = res.data.data[index]
				}
				this.ClassRoomList = this.newres
			}
		},
		components: {
			itemList,
			uniNavBar
		}
	}
</script>

<style lang="scss">
	.left {
		 svg{
			height: 40rpx;
			width: 40rpx;
		}

	}
</style>
